<?php
/**
 * Created by lsx.
 * User: lsx
 * Date: 2017/4/17
 * Time: 14:40
 */

namespace app\wechat\controller;


use icontroller\admin\AController;

use icontroller\admin\wechat\IWechatMenu;
use logic\admin\wechat\LWechatMenu;
use think\Controller;

class WechatMenu extends AController implements IWechatMenu
{
    private $logic;
    function __construct()
    {
        parent::__construct();
        $this->logic=new LWechatMenu();
    }

    public function index(){
        return view();
    }

    public function index_data(){
        $param=array(
            'keyword'=>input('keyword'),
            'limit'=>input('limit'),
            'offset'=>input('offset'),
            'ordinal'=>input('ordinal'),
            'order'=>input('order'),
        );
        $data=$this->logic->index_data($param);
        return $data;
    }

    public function add()
    {
        return view();
    }

    public function insert()
    {
        $param=array(
            'data'=>input('button/a'),
            'title'=>input('title')
        );

        return $this->logic->insert_data($param);
    }

    public function edit()
    {
        $id=input('id');
        $data=$this->logic->edit_data($id);
//        var_dump($data->toArray());die();
        $this->assign('data',$data->toArray());
        $this->assign('data_object',$data->data_source);
        return view();
    }
    public function update()
    {
        $id=input('id');
        $param=array(
            'data'=>input('button/a'),
            'title'=>input('title')
        );
        return $this->logic->update_data($id,$param);
    }

    public function delete()
    {
        $id=input('id');
        return $this->logic->delete_data($id);
    }

    public function push_to_online(){
        $id=input('id');
        return $this->logic->push_to_online_data($id);
    }

}